import axios from "./http.js";
import _ from "lodash";

/**
 *
 * 主播信息，包括招募和运营
 */

// 获取主播列表
export function getActorList(config) {
  let url = "/mps/anchor/list";
  const opts = _.merge({}, config || {});
  return axios.get(url, opts);
}
// 获取线索主播列表
export function getClueActorList(config) {
  let url = "/mps/anchor/clue_list";
  const opts = _.merge({}, config || {});
  return axios.get(url, opts);
}

// 获取合同主播列表
export function getAgreementActorList(config) {
  let url = "/bs/anchor/contract/list";
  const opts = _.merge({}, config || {});
  return axios.get(url, opts);
}

// 增加主播
export function addActor(data, config) {
  let url = "/mps/anchor/save";

  data = data || {};
  config = config || {};
  return axios.post(url, data, config);
}
// 修改主播资料
export function updateActor(data, config) {
  let url = "/mps/anchor/update";

  data = data || {};
  config = config || {};
  return axios.post(url, data, config);
}
// 获取主播个人信息
export function getActorInfo(config) {
  let url = "/mps/anchor/view";
  const opts = _.merge({}, config || {});
  return axios.get(url, opts);
}
// 删除主播
export function deleteActor(data, config) {
  let url = "/mps/anchor/delete/" + data.anchorId;

  data = data || {};
  config = config || {};
  return axios.post(url, data, config);
}

// 更改主播签约意愿
export function changeActorWish(data, config) {
  let url = "/mps/anchor/update_signwish";

  data = data || {};
  config = config || {};
  return axios.post(url, data, config);
}
// 更改主播签约状态
export function changeActorStatus(data, config) {
  let url = "/mps/anchor/update_status";

  data = data || {};
  config = config || {};
  return axios.post(url, data, config);
}
// 获取主播跟进记录
export function getActorRecord(config) {
  let url = "/mps/anchor/followup/list/" + config.params.anchorId;
  const opts = _.merge({}, config || {});
  return axios.get(url, opts);
}
// 新增主播跟进记录
export function addActorRecord(data, config) {
  let url = "/mps/anchor/followup/save";

  data = data || {};
  config = config || {};
  return axios.post(url, data, config);
}
// 获取该主播签约记录
export function getAgentWish(config) {
  let url = "/mps/anchor/appraise/list/" + config.params.anchorId;
  delete config.params.anchorId;
  const opts = _.merge({}, config || {});
  return axios.get(url, opts);
}

/* 运营 */

// 签约大厅
export function getHallList(config) {
  let url = "/mps/anchor/query_sign_hall";

  const opts = _.merge({}, config || {});
  return axios.get(url, opts);
}
// 运营获取我的签约意愿
export function getOffer(config) {
  let url = "/mps/anchor/getSignIntention";

  const opts = _.merge({}, config || {});
  return axios.get(url, opts);
}
// 添加运营报价
export function addOffer(data, config) {
  let url = "/mps/anchor/signIntention/";

  data = data || {};
  url += data.signIntention;
  delete data.signIntention;
  config = config || {};
  return axios.post(url, data, config);
}
// 运营获取想签主播列表
export function getWantSignActorList(config) {
  let url = "/mps/anchor/want_to_sign_list";

  const opts = _.merge({}, config || {});
  return axios.get(url, opts);
}

/**
 *
 *
 * 法务专用，获取法务一些信息
 */
export function addAgreementActor(data, config) {
  let url = "/bs/anchor/contract/save";

  data = data || {};
  config = config || {};
  return axios.post(url, data, config);
}
// 检查身份证是否重复
export function checkIdCard(data, config) {
  let url = "/bs/anchor/contract/checkIdCard";
  data = data || {};
  config = config || {};
  return axios.post(url, data, config);
}

// 获取该合同主播信息
export function getAgreementAgentInfo(config) {
  let url = "/bs/anchor/contract/view/" + config.params.anchorId;
  delete config.params.anchorId;
  const opts = _.merge({}, config || {});
  return axios.get(url, opts);
}
// 修改合同主播
export function updateAgreementActor(data, config) {
  let url = "/bs/anchor/contract/update";

  data = data || {};
  config = config || {};
  return axios.post(url, data, config);
}

// 更改主播签约状态-签约/解约
export function changeActorContractStatus(data, config) {
  let url = "/bs/anchor/contract/updateContractStatus";

  data = data || {};
  config = config || {};
  return axios.post(url, data, config);
}

// 更改主播签约状态-签约/解约
export function bindAgent(data, config) {
  let url = "/mps/anchor/bind_operator";

  data = data || {};
  config = config || {};
  return axios.post(url, data, config);
}

// 下载所有主播-不含主播线索
export function downloadActor(options) {
  let url = "/mps/anchor/export";
  const opts = _.merge({}, options || {});
  opts.responseType = "blob";
  return axios.get(url, opts);
}
// 下载主播线索
export function downloadClueActor(options) {
  let url = "/mps/anchor/exportClue";
  const opts = _.merge({}, options || {});
  opts.responseType = "blob";
  return axios.get(url, opts);
}

// 获取直播间主播信息
export function getLiveActorInfo(config) {
  let url = "/mps/anchor/viewLive";
  const opts = _.merge({}, config || {});
  return axios.get(url, opts);
}
// 新增直播间
export function addLive(data, config) {
  let url = "/mps/anchor/saveLiveRoom";

  data = data || {};
  config = config || {};
  return axios.post(url, data, config);
}
// 删除直播间
export function deleteLive(data, config) {
  let url = "/mps/anchor/deleteLiveRoom";

  data = data || {};
  config = config || {};
  return axios.post(url, data, config);
}

// 获取直播间的流水
export function getActorTurnover(config) {
  let url = "/bi/anchor/revenue";
  const opts = _.merge({}, config || {});
  return axios.get(url, opts);
}
// 获取直播间产生的利润
export function getActorProfit(config) {
  let url = "/mps/anchor/viewLive";
  const opts = _.merge({}, config || {});
  return axios.get(url, opts);
}

// 运营在签约大厅绑定主播
export function bindActorByAgent(data, config) {
  let url = "/mps/anchor/bind";

  data = data || {};
  config = config || {};
  return axios.post(url, data, config);
}

// // 获取自己绑定的运营
// export function getBindedActorList(config) {
//   let url = "/mps/anchor/viewLive";
//   const opts = _.merge({}, config || {});
//   return axios.get(url, opts);
// }
// 运营取消绑定主播
export function cancelBindActor(data, config) {
  let url = "/mps/anchor/unbind";

  data = data || {};
  config = config || {};
  return axios.post(url, data, config);
}

/* 联营工作台 */
// 获取主播列表
export function getActorListByUnion(data, config) {
  let url = "/bs/union/unionList";

  data = data || {};
  config = config || {};
  return axios.post(url, data, config);
}
// 增加主播
export function addActorByUnion(data, config) {
  let url = "/bs/union/addUnionAnchor";

  data = data || {};
  config = config || {};
  return axios.post(url, data, config);
}
// 导入主播
export function importActorByUnion(data, config) {
  let url = "/bs/union/addUnionAnchor";

  data = data || {};
  config = config || {};
  return axios.post(url, data, config);
}
// 修改主播资料
export function updateActorByUnion(data, config) {
  let url = "/bs/union/updateAnchor";

  data = data || {};
  config = config || {};
  return axios.post(url, data, config);
}
// 获取主播个人信息
export function getActorInfoByUnion(data, config) {
  let url = "/bs/union/getUnionDtl";
  data = data || {};
  config = config || {};
  return axios.post(url, data, config);
}
// 删除主播
export function deleteActorByUnion(data, config) {
  let url = "/bs/union/delUnion";

  data = data || {};
  config = config || {};
  return axios.post(url, data, config);
}
// 查看主播身份证是否存在-必须是不同渠道
export function checkActorIdcard(config) {
  let url = "/bs/union/checkIdCardOrWxNo";

  const opts = _.merge({}, config || {});
  return axios.get(url, opts);
}
